<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>

<div id="example"></div>
<script type="text/babel">
function Comp1 () {
  return <div>this is Comp1</div>
}
function Comp2 () {
  return <div>this is Comp2</div>
}

class Demo extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      i: 0
    };
  }

  handleClick () {
    this.setState({
      i: 1
    })
    debugger;
  }

  render() {
    return (
      <div>
        <button onClick={this.handleClick.bind(this)}>点击</button>
        {this.state.i === 0 ? <Comp1/> :<Comp2/>}
      </div>
    );
  }
}

ReactDOM.render(
  <Demo />,
  document.getElementById('example')
);

</script>

</body>
</html>